home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWDebug / Include / FWPriDeb.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  5.1 KB  |  143 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPriDeb.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWENVDEF_H
  11. #include "FWEnvDef.h"
  12. #endif
  13.  
  14. #ifndef FWPRIDEB_H
  15. #define FWPRIDEB_H
  16.  
  17. #ifndef SLDEBUG_H
  18. #include "SLDebug.h"
  19. #endif
  20.  
  21.  
  22. //========================================================================================
  23. //    class FW_CDebugConsole
  24. //========================================================================================
  25.  
  26. class FW_CDebugConsole
  27. {
  28. public:
  29.  
  30.     static FW_SDebugConsole* GetConsole();
  31.         // Get the currently installed debug console
  32.         
  33.     static FW_SDebugConsole* SetConsole(FW_SDebugConsole* console);
  34.         // Install a new debug console.
  35.         // The prior debug console is returned.
  36.  
  37.     static void RequireMessage(const char* message);
  38.         // Display the message, then throw a failure.
  39.         
  40.     static void AssertMessage(const char* message);
  41.         // Display the message, then throw a failure.
  42.         
  43.     static void FatalMessage(const char* message);
  44.         // Display the message, preferably without suspending execution.
  45.         
  46.     static void DebugMessage(const char* message);
  47.         // Suspend normal execution and display the message.
  48.         
  49.     static void LogMessage(const char* message);
  50.         // Display the message, preferably without suspending execution.
  51.         
  52.     static void Debugger();
  53.         // Suspend normal execution without displaying a message
  54.     
  55.     static void SubclassResponsibility(const char* method);
  56.         // Suspend normal execution displaying a message about the method
  57.     
  58. private:
  59.     FW_CDebugConsole();
  60.     FW_CDebugConsole(const FW_CDebugConsole& debugConsole);
  61.     FW_CDebugConsole& operator=(const FW_CDebugConsole& debugConsole);
  62.         // No instances of this class.
  63. };
  64.  
  65. //----------------------------------------------------------------------------------------
  66. // FW_CDebugConsole::GetConsole
  67. //----------------------------------------------------------------------------------------
  68.  
  69. inline FW_SDebugConsole* FW_CDebugConsole::GetConsole()
  70. {
  71.     return FW_PrivDebugConsole_GetConsole();
  72. }
  73.  
  74. //----------------------------------------------------------------------------------------
  75. // FW_CDebugConsole::SetConsole
  76. //----------------------------------------------------------------------------------------
  77.  
  78. inline FW_SDebugConsole* FW_CDebugConsole::SetConsole(FW_SDebugConsole* console)
  79. {
  80.     return FW_PrivDebugConsole_SetConsole(console);
  81. }
  82.  
  83.  
  84. //----------------------------------------------------------------------------------------
  85. //    FW_DEBUG_STRING
  86. //        This macro expands its argument into a string.  ANSI C hackery.  
  87. //        FW_DEBUG_STRING causes its argument to be expanded prior to calling 
  88. //        FW_DEBUG_STRING0.  The latter macro converts its (expanded) argument 
  89. //        to a string.
  90. //----------------------------------------------------------------------------------------
  91.  
  92. #define FW_DEBUG_STRING(x)   FW_DEBUG_STRING0(x)
  93. #define FW_DEBUG_STRING0(x)  #x
  94.  
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    FW_REQUIRE
  98. //        This check is always present in both the debug and release versions.  Use it
  99. //        when continuing execution would cause failure as in
  100. //
  101. //            FW_REQUIRE(ptr != NULL);
  102. //            ptr->Moby();
  103. //
  104. //        FW_REQUIRE does an FW_THROW.  Be sure that the throw is caught; don't let it 
  105. //        cross boundaries into/out of the part and the ODF shared library, as they will 
  106. //        frequently have been built using different exception handling packages (native 
  107. //        vs emulated).
  108. //
  109. //    FW_ASSERT
  110. //        This check is present *only* in debug versions.  No throw is done.
  111. //----------------------------------------------------------------------------------------
  112.  
  113.  
  114. //----------------------------------------------------------------------------------------
  115. //    The debugging macros are enabled only if debugging is turned on.  The debug console
  116. //    is always available in debug and release versions, but might be empty in the release
  117. //    version.
  118. //----------------------------------------------------------------------------------------
  119.  
  120. #ifdef FW_DEBUG
  121.  
  122. #define FW_DEBUGGER()                         FW_CDebugConsole::Debugger()
  123. #define FW_DEBUG_MESSAGE(message)             FW_CDebugConsole::DebugMessage(message)
  124. #define FW_LOG_MESSAGE(message)             FW_CDebugConsole::LogMessage(message)
  125. #define FW_SUBCLASS_RESPONSIBILITY(method)    \
  126.                                             FW_CDebugConsole::SubclassResponsibility(#method);    \
  127.                                             ev->_major = (exception_type) -1
  128. #define FW_ASSERT(f)  do if(!(f)) FW_CDebugConsole::AssertMessage( __FILE__ " @" FW_DEBUG_STRING(__LINE__) ": " #f); while (0)
  129. #define FW_REQUIRE(f) do if(!(f)) FW_CDebugConsole::RequireMessage(__FILE__ " @" FW_DEBUG_STRING(__LINE__) ": " #f); while (0)
  130.  
  131. #else
  132.  
  133. #define FW_DEBUGGER()                            ((void)0)
  134. #define FW_DEBUG_MESSAGE(message)                ((void)0)
  135. #define FW_LOG_MESSAGE(message)                    ((void)0)
  136. #define FW_ASSERT(f)                            ((void)0)
  137. #define FW_SUBCLASS_RESPONSIBILITY(method)        ((void)0)
  138. #define FW_REQUIRE(f)                            do if(!(f)) FW_CDebugConsole::RequireMessage(0) while (0)
  139.  
  140. #endif
  141.  
  142. #endif
  143.